package com.bilibili.server.service;

import com.bilibili.dubbo.api.db.UserApi;
import com.bilibili.model.db.User;
import com.bilibili.model.vo.HuanXinUserVo;
import com.bilibili.server.interceptor.UserHolder;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.stereotype.Service;

/**
 * @author HuangRongFu
 * 2021/11/23 星期二11:40 上午
 */

@Service
public class HuanXinService {

    @DubboReference
    private UserApi userApi;

    /**
     * 环信用户信息
     * @Return: ResponseEntity
     */
    public HuanXinUserVo findUser() {

        Long userId = UserHolder.getUserId();

        User user = userApi.findById(userId);

        if (user == null){

            return null;
        }

        return new HuanXinUserVo(user.getHxUser(), user.getHxPassword());
    }
}
